/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author salm
 */
public class FriendRequestsModel extends AbstractTableModel
{
    private ArrayList<String> requests = new ArrayList();
    
    @Override
    public int getRowCount() {
        return this.requests.size();
    }

    @Override
    public int getColumnCount() {
        return 1;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return this.requests.get(rowIndex);
    }
    
    public void addRequest(String friendName)
    {
        this.requests.add(friendName);
        this.fireTableRowsInserted(this.requests.size() - 1, this.requests.size());
    }
    
    public void removeRequest(String friendName)
    {
        int reqIndex = this.requests.indexOf(friendName);
        this.requests.remove(reqIndex);
        this.fireTableRowsDeleted(reqIndex, reqIndex);
    }

    /**
     * @return the requests
     */
    public ArrayList<String> getRequests() {
        return requests;
    }

    /**
     * @param requests the requests to set
     */
    public void setRequests(ArrayList<String> requests) {
        this.requests = requests;
    }
}
